<?php

namespace app\store\validate;

use think\Validate;

class IntegralGoodsValidate extends Validate
{
    protected $rule = [
        'sort' => 'require|integer|egt:0',
        'goods_id' => 'require|integer',
        'spec_type' => 'require|in:1,2',
        'redeem_price' => 'requireIf:spec_type,1|float',
        'redeem_integral' => 'requireIf:spec_type,1|float',
        'redeem_stock' => 'requireIf:spec_type,1|integer',
        'redeem_num' => 'integer',
        'status' => 'require|in:0,1',
    ];


    protected $message = [
        'id.require' => '非法请求',
        'id.integer' => '非法请求',
        'sort.require' => '排序不能为空',
        'spec_type.require' => '非法请求!',
        'redeem_price.require' => '请输入兑换价格!',
        'redeem_integral.require' => '请输入兑换积分!',
        'redeem_stock.require' => '请输入兑换库存!',
        'status.in' => '无效的状态值!',
    ];


    public function sceneSwitch()
    {
        return $this->only(['id','status'])
                    ->append('id', 'require|integer');
    }

    public function sceneEdit()
    {
    	return $this->only(['id','sort','redeem_price','redeem_integral','redeem_stock','spec_type','status'])
                    ->append('id', 'require|integer');
            
    }   
}